<template>
	<view style="height: 100vh; background-color: #FFFFFF;">
		<u-navbar title-color="#FFFFFF" height="48" back-icon-color="#FFFFFF" :border-bottom="false" :is-fixed="true" title="报警成功"
		:customBack="goHome"></u-navbar>
		<uc-content>
		<view class="view-center">
			<view class="content">
				{{noticeInfo.noticeContent}}
			</view>
			 
			<view class="buttonView">
				<u-button size="medium" style="width: 40%; margin-right: 10%;"   @click="show=true" type="success" >结束火情</u-button>
				<u-button type="success" size="medium" style="width: 40%;" @click="goHome">返回首页</u-button>
			</view>
		</view>
		<u-modal v-model="show" :content="content" :show-cancel-button="true" @cancel="show=false"  @confirm="confirm"/>
		</uc-content>	
	</view>
</template>

<script>
	export default {
		data() {
			return {
				noticeId: '',
				fireInfoId: '',
				noticeInfo: {},
				audioId: '',
				content: "如火情未扑灭，恶意结束火情信息将承担相应法律责任",
				show: false
			}
		},
		onLoad(e) {
			this.noticeId = e.noticeId
			this.fireInfoId = e.fireInfoId
			this.audioId = e.audioId
			if(e.mark == 1){
				this.utils.request("/api/app/user/getUserInfo", {}, "get", "app", true).then(res => {
					this.$store.commit('webSocket/WEB_SOCKET_INIT', res.data.ucId)
				}).catch(error => {
					console.log(error)
				})
			}
			this.utils.request("/api/app/notice/getInNoticeVo", {ucId:this.noticeId}, "post", "app", true).then(res => {
				this.noticeInfo = res.data
			}).catch(error => {
				console.log(error)
			})
			if(this.audioId){
				window.native.openAudio(this.audioId)
			}
		},
		methods: {
			confirm() {
				window.native.h5Camera()
				window.native.getUri(res=>{
					this.utils.request("/api/app/fireInfo/generateFireFinishPutFire", {
						ucId: this.fireInfoId,
						confirmFireFile:res.uri
					}, "post", "app", true).then(res => {
						this.goHome()
					}).catch(error => {
						console.log(error)
					})
				})
			},
			goHome(){
				this.utils.request("/api/app/user/getUserInfo", {}, "get", "app", true).then(res => {
					if(res.data.roleCode == "XZ-ADMIN" || res.data.roleCode == "XZ-YH"){
						//消灾企业用户
						uni.redirectTo({
							url:"/pages/index/index_xz"
						})
					} else if(res.data.roleCode == "WB-ADMIN" || res.data.roleCode == "WB-YH"){
						//维保企业用户
						uni.redirectTo({
							url:"/pages/index/index_wb"
						})
					}else if(res.data.roleCode == "JC-ADMIN" || res.data.roleCode == "JC-YH"){
							//维保企业用户
							uni.redirectTo({
								url:"/pages/index/index_jc"
							})
					}else{
						//其他企业用户
						uni.redirectTo({
							url:"/pages/index/index_qt"
						})
					}
				}).catch(error => {
					console.log(error)
				})
			}
		}
	}
</script>

<style lang="scss">
	.view-center{
		height: 25%;
		width: 80%;
		.content{
			height: 80%;
			width: 100%;
		}
		.buttonView{
			text-align: center;
			bottom: 10px;
			position: fixed;
			width: 100%;
			height: 20%;
		}
	}
</style>
